This is the readme file for the replication materials for "Unbundling the State: Legal Development in an Era of Global, Private Governance" by Michael O. Allen (michael_allen@fas.harvard.edu).

Latest revision: 2023-09-04

# Scripts

These replication materials are designed to be run after opening the "unbundling-io-replication.Rproj" project file with RStudio. Otherwise, you will need to set the working directory to the folder containing this readme file prior to running each R script. The Stata do files require assigning this folder as the working directory as well. The code to recreate all of the figures and tables in the paper can be found in the "scripts/" folder. The output for each script will be saved in either the "output/figures/" or "output/tables/" folder with a filename that reflects its label in the main text or appendix. The tables presented in the main text were made by hand from the full tables output by the relevant script (i.e., Table 1 is a simplified version of Table A6; Table 2 is from Table A7; and Table 3 is made up of Tables A14-A17).

# Data

The "data/" folder contains the datasets described in the main text and used to reproduce the all analyses in the paper.

The "data/trade" folder contains the yearly country correlations in contract-intensive trade (the "data/trade/n" folder) and non-contract intensive trade (in the "data/trade/rw" folder). Each year of data is contained in its own CSV. The "analysis_iv.R" script uses this data to calculate the instrument. "country_codes_V202201.csv" contains the table to match the country codes with ISO3c, which is used to merge with the main datasets.

# Output - Tables and Figures
Below I list all of the original tables and figures included in the main text and appendix along with the filename of the R or Stata script that can be used to replicate each. Each script can be run on its own. The resulting table or figure is stored in the "output" folder with a filename corresponding to its table/figure label in the text/appendix.

## Main Text

### Figures
  - Figure 1:  figure-1.R
  - Figure 2:  figure-2.R
  - Figure 3:  analysis_pm.R
  - Figure 4:  figure-4.R
  - Figure 5:  figure-5.R
  - Figure 6:  figure-6-and-A3.R
  - Figure 7:  figure-7.R
 
### Tables:
  - Table 1:   analysis_iv.R and analyses_iv.do (made from Table A6)
  - Table 2:   analysis_iv.R                    (made from Table A7)
  - Table 3:   analyses_icc.do                  (made from Tables A14-A17)
  
## Appendix
### Figures
  - Figure A1: analyses_pm.R
  - Figure A2: analyses_pm.R
  - Figure A3: figure-6-and-A3.R
  - Figure A4: analyses_pm.R
  - Figure A5: analysis_pm.R
  - Figure A6: analyses_pm_fraser.R
  - Figure A7: analyses_icc.do
  
### Tables
  - Table A1:  Recreated from Binder (2010), Chapter 12.
  - Table A2:  analyses_pm.R
  - Table A3:  analyses_pm.R
  - Table A5:  analyses_pm.R
  - Table A6:  analyses_iv.R
  - Table A7:  analyses_iv.R
  - Table A8:  analyses_iv.do
  - Table A9:  analyses_iv.R
  - Table A10: analyses_iv.R
  - Table A11: analyses_iv.R
  - Table A12: analyses_iv.R
  - Table A13: analyses_iv.R
  - Table A14: analyses_icc.do
  - Table A15: analyses_icc.do
  - Table A16: analyses_icc.do
  - Table A17: analyses_icc.do

  # Environment
  The replication package was created and last run using macOS 13.5.1 with R version 4.3.1 and StataMP 17.
  
  ## Main R Package versions
   - PanelMatch (2.0.1)
   - fixest (0.11.1)
   - didimputation (0.4.0)
   - sensemakr (0.1.5)
   - ivDiag (1.0.4)
   - rnaturalearth (0.3.3)
   - datatable (1.14.8)
   - modelsummary (1.4.1)
   - ggplot2 (3.4.3)

